﻿using HKB.Common;
using HKB.Web;
using HKB.Web.Admin;
using System;
using System.Data;
using System.Text;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;

public partial class Admin_Admin_PageLable : Admin, IRequiresSessionState
{
    public string PagelabelType = "";
    private PageLabelBll _plb = null;
    protected PageLabelBll plb
    {
        get
        {
            PageLabelBll plb;
            if (this._plb == null)
            {
                this._plb = new PageLabelBll(this.conn);
                plb = this._plb;
            }
            else
            {
                plb = this._plb;
            }
            return plb;
        }
    }
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.admin.CheckAdminPower(4))
        {
            base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "PageLabel");
            base.WriteRightErrMsg();
        }
        this.PagelabelType = Fetch.Get("types", "string");
        this.GridView1.DataSource = this.plb.GetPageLabelByType(this.PagelabelType);
        this.GridView1.DataBind();
        this.LableManage.Text = this.ShowPageLabelType();
    }
    public string ShowPageLabelType()
    {
        DataTable pageLabelType = this.plb.GetPageLabelType();
        StringBuilder stringBuilder = new StringBuilder();
        if (pageLabelType.Rows.Count > 0)
        {
            for (int i = 0; i < pageLabelType.Rows.Count; i++)
            {
                stringBuilder.Append(string.Concat(new string[]
				{
					"<a href=\"Admin_PageLable.aspx?types=",
					pageLabelType.Rows[i]["Type"].ToString(),
					"\">",
					pageLabelType.Rows[i]["Type"].ToString(),
					"</a> | "
				}));
            }
        }
        return stringBuilder.ToString();
    }
    protected void CopyButton_OnCommodn(object sender, CommandEventArgs e)
    {
        if (this.plb.CopyPageLabelByID(int.Parse(e.CommandArgument.ToString())))
        {
            this.GridView1.DataSource = this.plb.GetPageLabelByType(e.CommandName.ToString());
            this.GridView1.DataBind();
        }
    }
    protected void Delete_Click(object sender, CommandEventArgs e)
    {
        if (this.plb.DeletePageLabel(int.Parse(e.CommandArgument.ToString())))
        {
            this.GridView1.DataSource = this.plb.GetPageLabelByType(e.CommandName.ToString());
            this.GridView1.DataBind();
        }
    }
    protected void GridView1_DataBound(object sender, EventArgs e)
    {
        bool flag = base.admin.CheckAdminPower(4);
        bool flag2 = base.admin.CheckAdminPower(4);
        foreach (GridViewRow gridViewRow in this.GridView1.Rows)
        {
            if (!flag)
            {
                gridViewRow.Cells[4].Controls[1].Visible = false;
            }
            if (!flag2)
            {
                gridViewRow.Cells[4].Controls[0].Visible = false;
                gridViewRow.Cells[4].Controls[3].Visible = false;
            }
        }
    }
}
